package doctor

import (
	"context"
	"srv/config"
	"srv/internal/model/dao"
	__ "srv/proto"
	"srv/tools"
)

// 定义空接口
type DoctorService struct {
	__.UnimplementedDoctorServiceServer
}

// 实现方法
func (s *DoctorService) DoctorAdd(ctx context.Context, req *__.DoctorAddRequest) (resp *__.DoctorAddResponse, err error) {
	doctor := dao.Doctor{
		Name:        req.Name,
		Image:       req.Image,
		CollegeArea: req.CollegeArea,
		ClassArea:   req.ClassArea,
		Level:       req.Level,
		Price:       float64(req.Prices),
		Prices:      float64(req.Price),
		Intro:       req.Intro,
	}
	config.DB.Create(&doctor)
	tools.CreateEs(&doctor)
	return &__.DoctorAddResponse{Id: int64(doctor.ID)}, nil
}
